import { dosql } from "../tool/sqlTool";
import { comments } from "../tool/varType";
// 添加评论
export async function addComment(comments: comments) {
  return dosql(
    `insert into comments_ (blog_id,email,content,create_time) values (?,?,?,now())`,
    [comments.blog_id, comments.email, comments.content]
  );
}
// 读取评论表
export async function readComments(page: number, blog_id: string) {
  return dosql(
    `select * from comments_  where blog_id="${blog_id}" order by create_time desc limit ${
      (page - 1) * 10
    },10`,
    []
  );
}
export async function getTotal(blog_id: string) {
  return dosql(
    `select count(*) as total from comments_  where blog_id="${blog_id}"`,
    []
  );
}
